﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FoundationLib.Ifc.DependencyInjection.Configuration
{
	/// <summary>
	/// Represents the IOC container configuration section.
	/// </summary>
	public class IocConfigSection : ConfigurationSection
	{
		/// <summary>
		/// Creates a new <see cref="IocConfigSection"/> instance.
		/// </summary>
		public IocConfigSection()
			: base()
		{
		}

		/// <summary>
		/// Loads the IOC container configuration section from the configuration file.
		/// </summary>
		/// <returns>A <see cref="IocConfigSection"/> instance containing the configuration</returns>
		public static IocConfigSection FromConfiguration()
		{
			return (ConfigurationManager.GetSection("iocConfiguration") as IocConfigSection);
		}

		/// <summary>
		/// Gets a collection of container configurations.
		/// </summary>
		[ConfigurationProperty("containers", IsRequired = true)]
		[ConfigurationCollection(typeof(IocConfigElementCollection), AddItemName = "add", 
			ClearItemsName = "clear", RemoveItemName = "remove")]
		public IocConfigElementCollection Containers
		{
			get
			{
				return (this["containers"] as IocConfigElementCollection);
			}
		}
	}
}
